<!DOCTYPE html>
<html lang="en">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
	<title>维修店入驻</title>
	<script src="<%=basePath%>weixin/js/mui.min.js"></script>
	<script src="<%=basePath%>weixin/js/jquery.min.js"></script>
	<link rel="stylesheet" href="<%=basePath%>weixin/css/mui.min.css" />
	<link rel="stylesheet" href="<%=basePath%>weixin/css/order.css" />
	<link rel="stylesheet" href="<%=basePath%>weixin/css/base.css" />
	<link rel="stylesheet" href="<%=basePath%>weixin/css/style.css" />
	<script src="<%=basePath%>weixin/module/webuploader/webuploader.html5only.min.js" ></script>
	<script src="<%=basePath%>weixin/js/mui.picker.min.js"></script>
	<script src="<%=basePath%>weixin/js/mui.previewimage.min.js"></script>
	<script src="<%=basePath%>weixin/js/upload.js" ></script>
	<script src="<%=basePath%>weixin/js/page/valid.js"></script>
	<script src="<%=basePath%>weixin/js/area.js" ></script>
	<script src="<%=basePath%>weixin/module/layer_pc/layer.js"></script>
	<script src="<%=basePath%>weixin/js/page/common.js"></script>
</head>
<body class="bg-f5">
<div class="flow-chart clearfix">
	<div class="process" data="1">
		<span>1</span>
		<p>用户注册</p>
	</div>
	<div class="process" >
		<span>2</span>
		<p>身份认证</p>
	</div>
	<div class="process">
		<span>3</span>
		<p>等待审核</p>
	</div>
</div>
<div class="container-box m-top-30" id="steps1">
	<div class="input-group bg-white m-top-30">
		<input type="hidden" id="sid" name="sid" value="${userInfo.sid}" />
		<input type="hidden" id="audit_flag" name="audit_flag" value="${userInfo.audit_flag}" />
		<div class="input-group-item">
			<div class="input-group-icon"><i class="login-i login-i-1"></i></div>
			<div class="input-group-text must">
				<input type="text" id="readname" name="readname" maxlength="8" value="${userInfo.nickname}" placeholder="真实姓名">
			</div>
		</div>
		<div class="input-group-item">
			<div class="input-group-icon"><i class="login-i login-i-2"></i></div>
			<div class="input-group-text must">
				<input type="text" id="tel" name="tel" placeholder="手机号" value="${userInfo.tel}" maxlength="11">
			</div>
			<div class="input-group-text codeInput">
				获取验证码
			</div>
		</div>
		<div class="input-group-item">
			<div class="input-group-icon"><i class="login-i login-i-2"></i></div>
			<div class="input-group-text must">
				<input type="text" id="code" name="code" placeholder="验证码">
			</div>
		</div>
	</div>
	<a class="m-btn m-btn-block m-top-30 m-bottom-30" steps="1">下一步</a>
</div>
<div class="container-box m-top-30 hide" id="steps2">
	<div class="row-box">
		<div class="mui-card bg-none">
			<ul class="mui-table-view mui-table-1 bg-none">
				<li class="mui-table-view-cell mui-collapse mui-active">
					<a class="mui-navigate-right" href="#">身份证信息</a>
					<div class="mui-collapse-content">
						<div class="input-group bg-white">
							<div class="input-group-item">
								<div class="input-group-icon"><i class="login-i login-i-4"></i></div>
								<div class="input-group-text must">
									<input type="text" id="cardno" name="cardno" placeholder="身份证号" value="${storeInfo.cardno}" maxlength="18">
								</div>
							</div>
						</div>
						<div class="img-upload">
							<div id="frontpath" class="fileList">
								<input class="fileValue" name="frontpath" value="${storeInfo.frontpath}" type="hidden">
							</div>
							<div id="frontpathPick"><img src="<%=basePath%>weixin/img/icon-2.png" width="50" alt="上传照片" /></div>
							<p>身份证正面<span class="must-s"></span></p>
						</div>
						<div class="img-upload">
							<div id="sidepath" class="fileList">
								<input class="fileValue" name="sidepath" value="${storeInfo.sidepath}"  type="hidden">
							</div>
							<div id="sidepathPick"><img src="<%=basePath%>weixin/img/icon-2.png" width="50" alt="上传照片" /></div>
							<p>身份证反面<span class="must-s"></span></p>
						</div>
					</div>
				</li>
				<li class="mui-table-view-cell mui-collapse">
					<a class="mui-navigate-right" href="#">营业执照</a>
					<div class="mui-collapse-content">
						<div class="input-group bg-white">
							<div class="input-group-item">
								<div class="input-group-icon"><i class="login-i login-i-5"></i></div>
								<div class="input-group-text">
									<input type="text" name="operator" value="${storeInfo.operator}" placeholder="经营者名字" maxlength="8">
								</div>
							</div>
							<div class="input-group-item">
								<div class="input-group-icon"><i class="login-i login-i-6"></i></div>
								<div class="input-group-text">
									<input type="text" name="regname"  value="${storeInfo.regname}" placeholder="营业执照号" maxlength="30">
								</div>
							</div>
						</div>
						<div class="img-upload">
							<div id="certpath" class="fileList">
								<input class="fileValue" name="certpath"  value="${storeInfo.certpath}" type="hidden">
							</div>
							<div id="certpathPick"><img src="<%=basePath%>weixin/img/icon-2.png" width="50" alt="上传照片" /></div>
							<p>营业执照</p>
						</div>
					</div>
				</li>
				<li class="mui-table-view-cell mui-collapse">
					<a class="mui-navigate-right" href="#">店铺信息</a>
					<div class="mui-collapse-content">
						<div class="input-group bg-white">
							<div class="input-group-item">
								<div class="input-group-icon"><i class="login-i login-i-7"></i></div>
								<div class="input-group-text must">
									<input type="text" id="storename" name="storename" value="${storeInfo.storename}" placeholder="店铺名称" maxlength="15">
								</div>
							</div>
							<div class="input-group-item">
								<div class="input-group-icon"><i class="login-i login-i-8"></i></div>
								<div class="input-group-text must">
									<c:if test="${not empty userInfo.province_name }">
										<input type="text" readonly="readonly" id="address1" placeholder="所在地区"
											   value="${userInfo.province_name} ${userInfo.city_name} ${userInfo.area_name}" >
										<input type="text" readonly="readonly" value="${userInfo.town_name}" id="address3" placeholder="所在镇/乡/街道">
									</c:if>
									<c:if test="${empty userInfo.province_name }">
										<input type="text" readonly="readonly" id="address1" placeholder="所在地区" >
										<input type="text" readonly="readonly" id="address3" placeholder="所在镇/乡/街道">
									</c:if>
									<input type="text" id="address2" name="address" placeholder="店铺地址" value="${userInfo.address}" maxlength="50">
									<input type="hidden" id="provinceCode" value="${userInfo.province}" />
									<input type="hidden" id="cityCode" value="${userInfo.city}"  />
									<input type="hidden" id="areaCode" value="${userInfo.area}"  />
									<input type="hidden" id="townCode" value="${userInfo.town}"  />
								</div>
							</div>
							<div class="input-group-item">
								<div class="input-group-icon"><i class="login-i login-i-1"></i></div>
								<div class="input-group-text must">
									<input type="text" id="contacts" name="contacts" value="${storeInfo.contacts}" placeholder="联系人" maxlength="15">
								</div>
							</div>
							<div class="input-group-item">
								<div class="input-group-icon"><i class="login-i login-i-9"></i></div>
								<div class="input-group-text must">
									<input type="text" id="storeTel" name="storeTel" value="${storeInfo.tel1}" placeholder="联系电话" maxlength="15">
								</div>
							</div>
						</div>
					</div>
				</li>
			</ul>
		</div>
		<div class="recommend">
			<div class="r-title">
				是否有<c:if test="${promotion.userType=='5'}">服务商</c:if><c:if test="${promotion.userType=='1'}">维修店</c:if>推荐
			</div>
			<div class="recommendBtn">
				<div btn="true"><input type="radio" name="btn" value="true" <c:if test="${promotion!=null && promotion.code != '' }">checked</c:if> />有</div>
				<div btn="false"><input type="radio" name="btn" value="false"  <c:if test="${promotion==null || promotion.code == '' }">checked</c:if> />无</div>
			</div>
			<div class="r-centent  <c:if test="${promotion ==null || promotion.code == ''}">hide</c:if> ">
				<div>推荐码：<input type="text" style="width:110px;" onblur="ajaxWxPromotionrInfo()" value="${promotion.code}" id ="promotion_code_a" name="promotion_code" /></div>
				<div><c:if test="${promotion==null}">推荐人</c:if><c:if test="${promotion.userType=='5'}">服务商</c:if><c:if test="${promotion.userType=='1'}">维修店</c:if>姓名：<span id="in_service_name">${promotion.serviceName}</span></div>
				<div><c:if test="${promotion==null}">推荐人</c:if><c:if test="${promotion.userType=='1'}">维修店</c:if>手机号：<span id="in_service_tel">${promotion.serviceTel}</span></div>
			</div>
			<div class="r-centent <c:if test="${promotion!=null && promotion.code != '' }">hide</c:if>">
				<div>
					推荐服务商：平台服务商
				</div>
			</div>
		</div>
	</div>
	<a class="m-btn m-btn-block m-top-30 m-bottom-30" steps="2">下一步</a>
</div>
<div class="container-box m-top-30 hide" id="steps3">
	<div class="m-top-30">&nbsp</div>
	<div class="submit-tip">
		<div class="submit-tip-1">提交成功</div>
		<div class="submit-tip-2">请耐心等候</div>
	</div>
	<a href="javascript:void(0)" onclick="WeixinJSBridge.call('closeWindow');"  class="m-btn m-btn-block m-top-30">完成</a>
</div>
<script>
	var basePathUrl = "<%=basePath%>";
	var auditflag ="${userInfo.audit_flag}";
	var isInitializeTown = true;//初始化
	//$(function(){
		if(auditflag == '2' || auditflag == 2){
			document.querySelector('#steps1').classList.add('hide');
			document.querySelector('#steps2').classList.add('hide');
			document.querySelector('#steps3').classList.remove('hide');
			document.querySelectorAll('.flow-chart .process')[0].classList.add('active');
			document.querySelectorAll('.flow-chart .process')[1].classList.add('active');
			document.querySelectorAll('.flow-chart .process')[2].classList.add('active');
			$('.active span').html('&nbsp;');
			document.querySelector('.submit-tip-1').innerHTML = "您审核已通过";
			document.querySelector('.submit-tip-2').innerHTML = "请下载App客户端";
		} else if(auditflag == '0' || auditflag == '1') {
				document.querySelector('#steps1').classList.add('hide');
				document.querySelector('#steps2').classList.add('hide');
				document.querySelector('#steps3').classList.remove('hide');
				document.querySelectorAll('.flow-chart .process')[0].classList.add('active');
				document.querySelectorAll('.flow-chart .process')[1].classList.add('active');
				$('.active span').html('&nbsp;');
				if(auditflag == 0 || auditflag == '0'){
					document.querySelector('.submit-tip-1').innerHTML = "服务商审核中";
				} else if(auditflag == 1 || auditflag == '1'){
					document.querySelector('.submit-tip-1').innerHTML = "平台审核中";
				}
		}
	//});

	var apiWxStoreSave = function(data,elementBox,process,index){
		$.ajax({
			type:"post",
			url:"<%=basePath%>api/wx/store/save",
			//async:false,
			data : data,
			success : function(data){
				if(data.code==1){
					elementBox.window1.classList.add('hide');
					elementBox.window2.classList.add('hide');
					elementBox.window3.classList.remove('hide');
					document.querySelectorAll('.flow-chart .process')[1].classList.add('active');
					$('.active span').html('&nbsp;').unbind();
				} else {
					mui.toast(data.mem);
				}
				layer.close(index);
			}
		});
	};
	if(auditflag !='0' && auditflag !='1' && auditflag !='2'){
		(function(mui){
			common.init('register-2');
			upLoadSet([
				{
					fileListId : "frontpath",
					filePickerId : "frontpathPick",
					upLoadPath : "<%=basePath%>/upload.do",
					path : "${storeInfo.frontpath}",
					name : "file"
				},{
					fileListId : "sidepath",
					filePickerId : "sidepathPick",
					upLoadPath : "<%=basePath%>/upload.do",
					path : "${storeInfo.sidepath}",
					name : "file"
				},{
					fileListId : "certpath",
					filePickerId : "certpathPick",
					upLoadPath : "<%=basePath%>/upload.do",
					path : "${storeInfo.certpath}",
					name : "file"
				}
			]);
			var auditDescribe = "${userInfo.audit_describe}";
			if(auditflag=='-2'){
				setTimeout(function() {
					mui.toast("平台审核未通过<br>原因:"+auditDescribe,'da',3500);
				}, 800);
			} else if (auditflag=='-1') {
				setTimeout(function() {
					mui.toast("服务商审核未通过<br>原因:"+auditDescribe,'da',3500);
				}, 800);
			}
		})(mui);
	}
	function ajaxWxPromotionrInfo(){
		var index = layer.load(2,{shade: [0.2, '#393D49']});
		var promotionCode = $("#promotion_code_a").val();
		$("#in_service_name").html("");
		$("#in_service_tel").html("");
		if(promotionCode.length != 12 && promotionCode.length != 11){
			mui.toast("无效的推广码",'da',3500);
			layer.close(index);
			return ;
		}
		$.ajax({
			type:"POST",
			url:"<%=basePath%>api/wx/promotion/info",
			data:{
				'promotionCode' : promotionCode,
				'tm':new Date().getTime()
			},
			dataType:'json',
			cache: false,
			async: false,
			success: function(data){
				if(data.code==1){
					var jsonArr = eval("("+data.data+")");
					$("#in_service_name").html(jsonArr.serviceName);
					$("#in_service_tel").html(jsonArr.serviceTel);
				}else{
					mui.toast("无效的推广码",'da',3500);
				}
				layer.close(index);
			}, error: function(XMLHttpRequest, textStatus, errorThrown) {
				// alert(XMLHttpRequest.status+" | "+XMLHttpRequest.readyState+"|"+textStatus);
				mui.toast("Error:请联系管理员!",'da',3500);
				layer.close(index);
			}
		});
	}

	var telIsRegistered = false;
	var ajaxWxVerifyTel = function (tel,userType){
		var user_id = "${userInfo.sid}";
		$.ajax({
			type:"POST",
			url:basePathUrl+"ajax/wx/verify/tel",
			data:{
				'user_id' : user_id,
				'tel' : tel,
				'userType' : userType,
				'tm':new Date().getTime()
			},
			dataType:'json',
			cache: false,
			async: false,
			success: function(data){
				if(data.code==1){
					telIsRegistered =  true;
				}else{
					telIsRegistered = false;
				}
			}, error: function(XMLHttpRequest, textStatus, errorThrown) {
				alert(XMLHttpRequest.status+" | "+XMLHttpRequest.readyState+"|"+textStatus);
			}
		});
	}

</script>
</body>
</html>
